function alertSuccess(title, content){
    var jc = $.confirm({
        title: title,
        icon: 'glyphicon glyphicon-ok',
        content: content,
        //confirmButtonClass: "btn-success",
        confirmButton: '确定',
        cancelButton: false
    })
    jc.$content.addClass("text-center");
    jc.$content.css({"color":"#9A3036","font-size":"16px"});
};

function alertWarn(title, content){
    var jc = $.confirm({
        title: title,
        icon: 'glyphicon glyphicon-warning-sign',
        content: content,
        //confirmButtonClass: "btn-success",
        confirmButton: '关闭',
        cancelButton: false
    })
    jc.$content.addClass("text-center");
    jc.$content.css({"color":"#9A3036","font-size":"16px"});
};

function alertConfirm(title, content, process){
    var jc = $.confirm({
        title: title,
        icon: 'glyphicon glyphicon-warning-sign',
        content: content,
        confirmButtonClass: "btn-danger",
        cancelButtonClass: "btn-default",
        confirmButton: '确定',
        cancelButton: '取消',
        confirm: process,
        cancel: function(){
        }
    })
    jc.$content.addClass("text-center");
    jc.$content.css({"color":"#9A3036","font-size":"16px"});
};

function getQueryParas(url) {
    var queryParas = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.split("?")[1];
        var strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
            queryParas[strs[i].split("=")[0]]=strs[i].split("=")[1];
        }
    }
    return queryParas;
}

// 对Date的扩展，将 Date 转化为指定格式的String
// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符，
// 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
// 例子：
// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
// (new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18
Date.prototype.Format = function(fmt)
{ //author: meizz
    var o = {
        "M+" : this.getMonth()+1,                 //月份
        "d+" : this.getDate(),                    //日
        "h+" : this.getHours(),                   //小时
        "m+" : this.getMinutes(),                 //分
        "s+" : this.getSeconds(),                 //秒
        "q+" : Math.floor((this.getMonth()+3)/3), //季度
        "S"  : this.getMilliseconds()             //毫秒
    };
    if(/(y+)/.test(fmt))
        fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
    for(var k in o)
        if(new RegExp("("+ k +")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
    return fmt;
}

function addDate(dd,dadd){
    var a = dd.valueOf()
    a = a + dadd * 24 * 60 * 60 * 1000
    a = new Date(a)
    return a;
}

function getTimeSlotFromDay(dd){
    var date = (dd).Format("yyyy-MM-dd 00:00:00");
    var start = new Date(date.replace(/-/g,"/")).getTime();
    var end = start + 24*60*60*1000 - 1;
    console.log(start+"  "+end);
    return {start: start, end: end};
}

function URLdecode(str) {
    if(str == null) return "";
    var ret = "";
    for(var i=0;i<str.length;i++) {
        var chr = str.charAt(i);
        if(chr == "+") {
            ret += " ";
        }else if(chr=="%") {
            var asc = str.substring(i+1,i+3);
            if(parseInt("0x"+asc)>0x7f) {
                ret += decodeURI("%"+ str.substring(i+1,i+9));
                i += 8;
            }else {
                ret += String.fromCharCode(parseInt("0x"+asc));
                i += 2;
            }
        }else {
            ret += chr;
        }
    }
    return ret;
}
